<HTML><HEAD><TITLE>occurs(?Simple, ?Term)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">Comparing and Sorting</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>occurs(?Simple, ?Term)</H1>
Succeeds if Simple is a variable or an atomic type that occurs in the term
Term.


<DL>
<DT><EM>Simple</EM></DT>
<DD>Variable or atomic type.
</DD>
<DT><EM>Term</EM></DT>
<DD>An arbitrary term.
</DD>
</DL>
<H2>Description</H2>
   Succeeds if Simple is a variable, an atom or a number occurring in the
   term Term.

<P>

<H3>Modes and Determinism</H3><UL>
<LI>occurs(?, ?) is semidet
</UL>
<H3>Fail Conditions</H3>
Fails if Simple does not occur in the term Term.
<H3>Exceptions</H3>
<DL>
<DT><EM>(5) type error </EM>
<DD>If Simple is neither a variable, an atom nor a number.
</DL>
<H2>Examples</H2>
<PRE>
   Success:
   occurs(a,a).
   occurs(X,f(a,b,c,X)).
   occurs(+,f(+,-)).
   occurs(a,[b,c,a,g,a]).
   occurs([ ],[a,b]).
   occurs(1,[A|1]).
   occurs(1.0,[1.0|B]).
   Fail:
   occurs(a,b).
   occurs(X,f(Y,Z)).
   occurs(X,Y).
   occurs(1,"2314").
   occurs([], [a,b|c]).
   Error:
   occurs("str",f("str1","str2","str")). (Error 5)
   occurs([a],[a,b]).                    (Error 5)
   occurs(f(a,b),f(a,b)).                (Error 5)



</PRE>
<H2>See Also</H2>
<A HREF="../../kernel/termcomp/instance-2.html">instance / 2</A>, <A HREF="../../kernel/termcomp/variant-2.html">variant / 2</A>
</BODY></HTML>
